//
//  ChatHeaderView.m
//  ChatForHot
//
//  Created by FLY on 2018/10/16.
//  Copyright © 2018年 FLY. All rights reserved.
//

#import "ChatHeaderView.h"

@implementation ChatHeaderView

- (instancetype)init
{
    self = [super init];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];//HOTCHATrgb(242, 242, 242);
        [self addSubview:self.HOTCHATimgView];
        [self addSubview:self.HOTCHATtitleLab];
        
        [self addSubview:self.HOTCHATgustHeadPic1];
        [self addSubview:self.HOTCHATgustHeadPic2];
        [self addSubview:self.HOTCHATgustHeadPic3];
        [self addSubview:self.HOTCHATarrowImgView];
        [self addSubview:self.HOTCHATlineView1];
        [self addSubview:self.HOTCHATlineView2];
        
        [self.HOTCHATimgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).mas_offset(15);
            make.centerY.equalTo(self);
            make.width.mas_equalTo(19);
            make.height.mas_equalTo(20);
        }];
        [self.HOTCHATtitleLab mas_updateConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.HOTCHATimgView.mas_right).offset(15);
            make.centerY.equalTo(self);
        }];
        [self.HOTCHATarrowImgView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(7);
            make.height.mas_equalTo(11);
            make.centerY.equalTo(self);
            make.right.equalTo(self.mas_right).offset(-15);
        }];
        [self.HOTCHATgustHeadPic1 mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.HOTCHATarrowImgView.mas_left).offset(-15);
            make.width.height.mas_equalTo(32);
            make.centerY.equalTo(self);
        }];
        [self.HOTCHATgustHeadPic2 mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.HOTCHATgustHeadPic1.mas_left).offset(12);
            make.width.height.mas_equalTo(32);
            make.centerY.equalTo(self);
        }];
        [self.HOTCHATgustHeadPic3 mas_updateConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.HOTCHATgustHeadPic2.mas_left).offset(12);
            make.width.height.mas_equalTo(32);
            make.centerY.equalTo(self);
        }];
        [self.HOTCHATlineView1 mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.left.right.with.bottom.equalTo(self);
//            make.height.mas_equalTo(0.8);
            make.bottom.equalTo(self).mas_offset(-1);
            make.left.width.right.equalTo(self);
            make.height.mas_equalTo(1);
        }];
        [self.HOTCHATlineView2 mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.left.right.with.top.equalTo(self);
//            make.height.mas_equalTo(0.8);
//
            make.left.right.width.top.equalTo(self);
            make.height.mas_equalTo(1);
        }];
    }
    return self;
}
- (void)setHOTCHATguestArr:(NSArray *)HOTCHATguestArr{
    
    _HOTCHATguestArr = HOTCHATguestArr;
    
    [self HOTCHATsetGuestHeaderImgView:self.HOTCHATgustHeadPic1 index:0];
    [self HOTCHATsetGuestHeaderImgView:self.HOTCHATgustHeadPic2 index:1];
    [self HOTCHATsetGuestHeaderImgView:self.HOTCHATgustHeadPic3 index:2];
}

- (void)HOTCHATsetGuestHeaderImgView:(UIImageView *)imgView index:(NSInteger )index{
    if (index < self.HOTCHATguestArr.count) {
        [imgView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",APIHEADER,[self.HOTCHATguestArr objectAtIndex:index]]] placeholderImage:[UIImage imageNamed:@"personal_atatar_but_h"]];
    }else{
        imgView.image = nil;
    }
}
//lazzy
- (UIImageView *)HOTCHATimgView{
    
    if (_HOTCHATimgView == nil) {
        
        _HOTCHATimgView = [[UIImageView alloc]init];
        _HOTCHATimgView.image = [UIImage imageNamed:@"m_ic_visitor"];
    }
    return _HOTCHATimgView;
}
- (UILabel *)HOTCHATtitleLab{
    if (_HOTCHATtitleLab == nil) {
        _HOTCHATtitleLab = [[UILabel alloc] init];
        _HOTCHATtitleLab.font = [UIFont systemFontOfSize:14];
        _HOTCHATtitleLab.textColor = HOTCHATHexColor(0x3D3D3D);
        _HOTCHATtitleLab.text = NSLocalizedString(@"StrN047", nil);;
    }
    return _HOTCHATtitleLab;
}
- (UIImageView *)HOTCHATgustHeadPic1{
    if (_HOTCHATgustHeadPic1 == nil) {
        _HOTCHATgustHeadPic1 = [[UIImageView alloc] init];
        _HOTCHATgustHeadPic1.layer.cornerRadius = 16;
        _HOTCHATgustHeadPic1.clipsToBounds = YES;
        _HOTCHATgustHeadPic1.layer.borderWidth = 1;
        _HOTCHATgustHeadPic1.layer.borderColor = [UIColor whiteColor].CGColor;
        _HOTCHATgustHeadPic1.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _HOTCHATgustHeadPic1;
}
- (UIImageView *)HOTCHATgustHeadPic2{
    if (_HOTCHATgustHeadPic2 == nil) {
        _HOTCHATgustHeadPic2 = [[UIImageView alloc] init];
        _HOTCHATgustHeadPic2.layer.cornerRadius = 16;
        _HOTCHATgustHeadPic2.clipsToBounds = YES;
        _HOTCHATgustHeadPic2.layer.borderWidth = 1;
        _HOTCHATgustHeadPic2.layer.borderColor = [UIColor whiteColor].CGColor;
        _HOTCHATgustHeadPic2.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _HOTCHATgustHeadPic2;
}
- (UIImageView *)HOTCHATgustHeadPic3{
    if (_HOTCHATgustHeadPic3 == nil) {
        _HOTCHATgustHeadPic3 = [[UIImageView alloc] init];
        _HOTCHATgustHeadPic3.layer.cornerRadius = 16;
        _HOTCHATgustHeadPic3.clipsToBounds = YES;
        _HOTCHATgustHeadPic3.layer.borderWidth = 1;
        _HOTCHATgustHeadPic3.layer.borderColor = [UIColor whiteColor].CGColor;
        _HOTCHATgustHeadPic3.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _HOTCHATgustHeadPic3;
}
- (UIImageView *)HOTCHATarrowImgView{
    if (_HOTCHATarrowImgView == nil) {
        _HOTCHATarrowImgView = [[UIImageView alloc] init];
        _HOTCHATarrowImgView.image = [UIImage imageNamed:@"all_more"];
    }
    return _HOTCHATarrowImgView;
}
- (UIView *)HOTCHATlineView1{
    
    if (_HOTCHATlineView1 == nil) {
        
        _HOTCHATlineView1 = [[UIView alloc]init];
        _HOTCHATlineView1.backgroundColor = HOTCHATHexColor(0xF0F0F0);
    }
    return _HOTCHATlineView1;
}
- (UIView *)HOTCHATlineView2{
    
    if (_HOTCHATlineView2 == nil) {
        
        _HOTCHATlineView2 = [[UIView alloc]init];
        _HOTCHATlineView2.backgroundColor = HOTCHATHexColor(0xF0F0F0);
    }
    return _HOTCHATlineView2;
}
@end
